

<script setup>
import { ref, onMounted } from "vue";
const emit = defineEmits(["getIndex"]);
const props = defineProps({
  list: Array,
});
const getSrc = (index) => {
  emit("getIndex", index);
};
</script>

<template>
  <div class="scrollList">
    <div
      v-for="(item, index) in props.list"
      :key="index"
      :style="index + 1 === props.list.length/2 ? 'margin:auto' : ''"
    >
      <span :title="getSrc(index)"></span>
      <image mode="widthFix" :src="item.src"></image>
      <slot ></slot>
    </div>
  </div>
</template>
<style lang="scss">
.scrollList {
  background-color: #ececec;
  margin: 5px;
  columns: 2;
  column-gap: 5px;

  div {
    background-color: #fcfcfc;
    border-radius: 10px;
    margin: 0;
    padding: 0;
    margin-bottom: 5px;
    padding: 10px;

    span {
      display: block;
    }

    image {
      width: 100%;

      & {
        box-shadow: 3px 3px 5px #888888;
      }
    }
  }
}
</style>